﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MBSBusinessEntities;
using System.Transactions;
using MBSVO;
namespace MBSBLC
{
    public partial class BLC
    {
        #region Cinema

        CinemaBE cinemabe;

        public static string GetCinemaException()
        {
            return CinemaBE.ErrorMessage;
        }



        public bool AddCinema(string CinemaName, string Location, string NumOfScreens)
        {

            try
            {
                CinemaBE cinemabe = new CinemaBE(CinemaName, Location, Convert.ToInt32(NumOfScreens));

                return cinemabe.Add();
            }

            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return false;
            }


        }

        public bool DeleteCinema(int CinemaID)
        {
            cinemabe = new CinemaBE();

            return cinemabe.Delete(CinemaID);


        }

        public bool UpdateCinema(string CinemaName ,string Location, string NumOfScreens)
        {
            
            CinemaBE cinemabe = new CinemaBE();
            cinemabe = cinemabe.GetCinemaByID(cinemabe.GetIDbyName(CinemaName));
            cinemabe.CinemaName = CinemaName;
            cinemabe.Location = Location;
            cinemabe.NumOfScreens = Convert.ToInt32(NumOfScreens);
            return cinemabe.Update();
        }


        public CinemaVO GetCinemaByID(int CinemaID)
        {
            cinemabe = new CinemaBE();
            cinemabe = cinemabe.GetCinemaByID(CinemaID);
            CinemaVO cinemaVO = BLCUtility.convertCinemaBEtoVO(cinemabe);
            return cinemaVO;
        }

                
        public Dictionary<int, string> GetAllCinemas()
        {

            CinemaBE cinema = new CinemaBE();

            List<CinemaBE> cinlist = cinema.GetAllCinemas();

            Dictionary<int, string> dct = new Dictionary<int, string>();

            foreach (CinemaBE cinematemp in cinlist)
            {
                dct.Add(cinematemp.CinemaID, cinematemp.CinemaName);

            }

            return dct;

        }

        public Dictionary<int, string> GetAllCinemasToDisplay()
        {

            CinemaBE cinemaBE = new CinemaBE();

            List<CinemaBE> cinemaBEList = cinemaBE.GetAllCinemasToDisplay();

            Dictionary<int, string> cinemaDictionary = new Dictionary<int, string>();

            foreach (CinemaBE cinemaBETemp in cinemaBEList)
            {
                cinemaDictionary.Add(cinemaBETemp.CinemaID, cinemaBETemp.CinemaName);

            }

            return cinemaDictionary;

        }

        

        #endregion
    }
}
